/** @author mike **/
package Controllers;

import Views.FrmLogin;

public class Controller_Login {
    private FrmLogin _loginWindow;
    private Controller_MainWindow _mainController;
    
    public Controller_Login(FrmLogin loginWindow, Controller_MainWindow controller)
    {
        _loginWindow = loginWindow;
        _mainController = controller;
    }
    
    public void ShowLoginWindow()
    {
        _loginWindow.Show();
    }
    
    public void HideLoginWindow()
    {
        _loginWindow.Hide();
    }
    
    public void CheckUser(String username, char[] password)
    {
        //try dao.loadUser
        boolean success = false;
        //fail = dao.loadUser; sau mainController.loadUser 
        success = _mainController.CheckUser(username, password);
        if (success == false)
        {
            _loginWindow.ShowErrorMessage("login failed. incorrect user or password");
        }
        else
        {
            _loginWindow.Hide();
        }
    }
}
